package com.game.dao;


import com.dats.db.DatS;
import com.dats.entity.CacheBean;
import com.dats.pool.DatSPool;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @author sig
 * @since 2016/9/26
 */
public class DatSDao {

    public static long loadLong(String sql) {
        return DatS.loadLong(DatSPool.userAlias, sql);
    }

    public static <T extends CacheBean> T loadBean(Class<T> clazz) {
        return DatS.loadBean(DatSPool.userAlias, clazz);
    }

    public static <T extends CacheBean> T loadBeanByValue(Class<T> clazz,
                                                          long value) {
        return DatS.loadBeanByValue(DatSPool.userAlias, clazz, value);
    }

    public static <T extends CacheBean> void saveBean(T t) {
        DatS.saveObj(DatSPool.userAlias, t);
    }

    public static <T extends CacheBean> List<T> loadBeanList(Class<T> clazz) {
        return DatS.loadBeanList(DatSPool.userAlias, clazz);
    }

    public static <T extends CacheBean> List<T> loadBeanListByValue(Class<T> clazz,
                                                                    long value) {
        return DatS.loadBeanListByValue(DatSPool.userAlias, clazz, value);
    }

    public static <T extends CacheBean> void saveBeanList(Collection<? extends T> list) {
        DatS.saveList(DatSPool.userAlias, list);
    }

    public static <T extends CacheBean> Map<Object, T> loadBeanMap(Class<T> clazz) {
        return DatS.loadBeanMap(DatSPool.userAlias, clazz);
    }

    public static <T extends CacheBean> void saveDel(T t) {
        DatS.saveDel(DatSPool.userAlias, t);
    }

    public static <T extends CacheBean> void saveDelList(List<T> list) {
        DatS.saveDelList(DatSPool.userAlias, list);
    }

    public static void delete(String tableName) {
        DatS.delete(DatSPool.userAlias, tableName);
    }
}
